const Controller = require('egg').Controller

/**
 * @controller draft 草稿箱
 */
class DraftController extends Controller {
	/**
	 * @summary 草稿箱列表
	 * @description 草稿箱列表
	 * @router get /admin/drafts
	 * @request query number pageSize eg:10 页尺寸
	 * @request query number pageNum eg:1 页码
	 */
	async index() {
		const ctx = this.ctx
		try {
			const { count, rows } = await ctx.service.draft.index(
				ctx.request.query
			)
			const data = {
				list: rows,
				total: count,
			}
			ctx.helper.success(data)
		} catch (e) {
			ctx.helper.error(e)
		}
	}
}

module.exports = DraftController
